class EnemySpawner {
  int enemyType;
  
  GameWindow gameWindow;
  EnemySpawner(GameWindow gw) {
    enemyType = 0;
    EnemySpaceShip enemy = new EnemySpaceShip('TROLL');
    this.gameWindow = gw;
    this.gameWindow.addChild(enemy);
    window.setInterval(addEnemy, 300);
  }
  
  void addEnemy() {
    num rand = Math.random();
    EnemySpaceShip enemy;
    if (enemyType < 3) {
      enemy = new EnemySpaceShip('TROLL');      
    }
    else {
      enemy = new EnemySpaceShip('BEAM');
    }
    enemy.setX(699);
    this.gameWindow.addChild(enemy);
    
    enemyType++;
    if (enemyType == 6) {
      enemyType = 0;
    }
  }
}
